<template>
    <div class="navbarContainer">
        <el-form ref="form"
                :model="form"
                label-width="140px"
                @submit.native.prevent
                >
            <el-row>
                <el-col :span="10" :xs="20" :sm="19" :md="19" :lg="19" :xl="19">
                    <el-form-item >
                        <template slot="label">
                            {{M2('发送设置')}}:
                        </template>
                        <el-radio-group size="mini"  v-model="form.sendType">
                            <el-radio-button @click.native="clickRadioSearch('sendType',item.label,$event)" v-for="item in timeList" :key="item.timeEnum" :label="item.label">{{ M2(item.name) }}</el-radio-button>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
                <el-col :xs="4" :sm="5" :md="5" :lg="5" :xl="5">
                    <el-form-item label-width="10px">
                        <div class="searchBox">
                            <el-input :placeholder="M2('消息来源/配置Title/备注')"
                                v-model="putSearch"
                                size='mini'
                                class="input-with-select"
                                clearable
                                @change="searchSomething"
                                @keyup.enter.native="searchSomething"
                                >
                            </el-input>
                            <el-button type="primary" @click="searchSomething">{{M2('搜索')}}</el-button>
                            <!-- <el-checkbox  class="search-check" v-model="form.selectCheck" :label="1">{{M2('在筛选条件中搜索')}}</el-checkbox>
                            <span class="more-search" @click="clickSearchMore()"  v-track="{triggerType:'click',currentUrl: $route.path,behavior:'批量查询'}">
                                {{M2('批量查询')}}
                            </span> -->
                        </div>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="10" :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                    <el-form-item >
                        <template slot="label">
                            {{M2('消息类型')}}:
                        </template>
                        <el-radio-group size="mini"  v-model="form.messageType">
                            <el-radio-button @click.native="clickRadioSearch('messageType',item.label,$event)" v-for="item in messageTypeList" :key="item.label" :label="item.label">{{ M2(item.name) }}</el-radio-button>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
                <el-col :span="10" :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                    <el-form-item >
                        <template slot="label">
                            {{M2('来源状态')}}:
                        </template>
                        <el-radio-group size="mini"  v-model="form.status">
                            <el-radio-button @click.native="clickRadioSearch('status',item.label,$event)" v-for="item in statusList" :key="item.label" :label="item.label">{{ M2(item.name) }}</el-radio-button>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <searchMoreDialog ref="searchMoreDialog" @searchMorething='searchMorething'></searchMoreDialog>
    </div>
</template>
<script>
import { trim } from '@/utils/tools.js';
import { getSampleValidatorList } from '@/api/user.js'
export default {
    name: 'newProductNaver',
    components:{
        searchMoreDialog:() => import('@/components/common/searchMoreDialog'),
    },
    data () {
        return {
            putSearch:null,
            // 1:未提交  2：待分配   3：样品确认中   4：结果输出中   5：合格    6：改进后通过(产前样)    7：不合格     8：已取消
            timeList:[
                {
                    name:'全部',
                    label:null,
                },
               
                {
                    name:'默认',
                    label:0,
                },
                {
                    name:'检查',
                    label:1,
                },
                {
                    name:'支持转发',
                    label:2,
                },
            ],
            messageTypeList:[
                {
                    name:'全部',
                    label:null,
                },
               
                {
                    name:'Markdown',
                    label:0,
                },
                {
                    name:'卡片',
                    label:1,
                },
                {
                    name:'审批',
                    label:2,
                },
            ],
            statusList:[
                {
                    name:'全部',
                    label:null,
                },
               
                {
                    name:'允许发送',
                    label:0,
                },
                {
                    name:'忽略',
                    label:1,
                },
                {
                    name:'禁用',
                    label:2,
                },
            ],
            form: {
                status: null ,//状态   1:未提交  2：待分配   3：样品确认中   4：结果输出中   5：合格    6：改进后通过(产前样)    7：不合格     8：已取消
                search: null, //搜索(供应商、开发ID、sku别名、sku、申请单号)
                messageType:null,
                sendType:null,
            }
        }
    },
    watch:{
        form:{
            handler:function(val){
                this.tableParams = val
                this.$emit('putTableList',this.tableParams)          
            },
            deep:true
        },
    },
    created() {
        // this.init()
    },
    mounted(){
        this.$nextTick(res => {
            if(this.$route.query.search){
                this.putSearch = this.$route.query.search
            }
        })
        this.addTitleLable()
    },
    methods: {
        addTitleLable(){
            document.querySelectorAll('.navbarContainer .el-form-item__label').forEach(item => {
                if(!item.getAttribute('title')){
                    item.setAttribute('title',item.innerHTML)
                }
            })
        },
        init() {
        },
        searchMorething(list){
            this.searchMore = { 
                parametersType:list.parametersType,
                parameters:list.parameters,
            }
            this.$emit('putTableList',this.searchMore)
        },
        clickSearchMore() {
            this.$refs.searchMoreDialog.openDialog()
        },
        clickRadioSearch(name,value,el) {
            if (el.target.tagName === 'INPUT') return
            this.$set(this.form,name,value)
            this.$set(this.form,'search1',false)
            this.$set(this.form,'almorlist',Math.random())
        },
        searchSomething(){
            this.$set(this.form,'search',trim(this.putSearch))
            this.$set(this.form,'search1',true)
            this.$set(this.form,'almorlist',Math.random())
        }
    }
}
</script>

<style  lang="scss" scoped>
::v-deep.checkbox-status {
    display: inline-block;
    .el-checkbox.is-bordered {
        margin-right: 0px;
        margin-left: 5px;
        height: 25px;
        top: 2px;
        padding: 2px 3px;
    }
}
.navbarContainer {
    padding: 5px;
    background-color: #ffffff;
    ::v-deep .el-form-item__label {
        color: #3366cc !important;
        font-weight: bold; 
        line-height: 30px; 
        overflow: hidden;
        -webkit-box-orient: vertical;
        text-overflow: ellipsis;
        white-space: nowrap;
        padding-left: 10px;
    }
    ::v-deep .el-form-item__content{
        font-size: 12px !important;
        line-height: 30px;
    }
    ::v-deep .el-form-item {
        margin-bottom: 0px;
    }
    ::v-deep .el-radio-button{
        line-height: 2;
        margin: 3px 4px;
        .el-radio-button__inner {
            padding: 5px 10px;
            color: #333 ;
            border-radius: 2px;
            border: 1px solid #DCDFE6;
            border-left: 1px solid #DCDFE6;
            &:hover {
                border: 1px solid #3366cc;
                border-left: 1px solid #3366cc;
                color: #3366cc;
            }
        }  
    }
    ::v-deep .el-radio-button__orig-radio:checked + .el-radio-button__inner {
        box-shadow: 0px 0 0 0 #3366cc;
    }
    ::v-deep .success-radio {
        border: 1px solid #ccc;
        display: inline-block;
        margin-right: 10px;
        height: 25px;
        line-height: 25px;
        position: relative;
        top: 5px;
        padding-right: 10px;
        // background: #e8f0f7;
        .el-radio__input {
            border-right:1px solid #ccc;
            line-height: 23px;
        }
    }
}
.searchBox{
    display: flex;
    .el-button{
        height: 28px;
        margin-top: 1px;
        line-height: 3px;
        padding: 12px 12px;
        font-size: 12px;
        margin-right: 10px;
    }
    .more-search {
        color: #3366cc;
        position: absolute;
        right: 10px;
        bottom: -25px;
        cursor: pointer;
        z-index: 111;
    }
    .search-check {
        position: absolute;
        bottom:-25px;
        left: 0;
    }
}
</style>
<style>
    .is-active .el-radio-button__inner {
        color: #fff !important;
    }
</style>